<template>
  <div class="container">
    <div v-for="el in asideList" :key="el.title">
      <router-link
        v-if="el.type == 'item'"
        tag="div"
        :to="el.link"
        class="item"
        :key="el.title"
      >
        <i :class="[el.iconfont, 'iconfont']"></i>
        <span>{{ el.title }}</span>
      </router-link>
      <div class="group" v-if="el.type == 'group'">
        <div class="group-flag">{{ el.title }}</div>
        <router-link
          v-for="el in el.childItem"
          :key="el.title"
          tag="div"
          :to="el.link + el.flag"
          class="item"
        >
          <i :class="[el.iconfont, 'iconfont']"></i>
          <span>{{ el.title }}</span>
        </router-link>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  computed: {
    asideList() {
      return this.$store.state.asideList;
    },
  },
};
</script>

<style scoped lang="less">
@import url(../../assets/iconfont/iconfont.css);
.container {
  height: 100%;
  .item {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    border-left: 3px solid transparent;
    transition: background-color 0.5s;
    i {
      font-size: 22px;
    }
    span {
      padding-left: 12px;
      font-size: 14px;
    }
    &:hover {
      background-color: rgba(255, 255, 255, 0.12);
    }
  }
  .router-link-exact-active {
    border-left: 4px solid rgb(63, 128, 192);
    background-color: rgba(255, 255, 255, 0.12);
    color: rgb(63, 128, 192);
    & > i {
      color: inherit;
    }
    & > span {
      color: inherit;
    }
  }
}
</style>